#pragma once
#include <fstream>
#include <map>
#include <boost/filesystem/path.hpp>
#include "TopicId.h"
#include "ImportExport.h"

namespace ja2
{
	//! Debug manager.
	class DebugManager : boost::noncopyable
	{
		// Enums
	public:
		//! Register command.
		enum RegisterCommand
		{
			RC_ADD,
			RC_REMOVE
		};
		//! Debug level.
		enum DebugLevel
		{
			DL_0,
			DL_1,
			DL_2,
			DL_3
		};

		// Typedefs
	private:
		typedef std::map<Topic, bool> TopicMap_t;

		// Attributes
	private:
		//! Log file.
		std::ofstream m_Log;
		//! Should we record to file.
		bool m_RecordToFile;
		//! Should we record to debugger.
		bool m_RecordToDebugger;
		//! Debug topics.
		TopicMap_t m_Topics;

		// Operations
	public:
		//! Topic enabled.
		JA2_CORE_API bool topic_enabled(Topic TopicId) const;
		//! Debug message.
		JA2_CORE_API void debug_message(const char *SourceFile, long LineNum, const char *String);
		//! Debug message real.
		JA2_CORE_API void debug_message_real(Topic TopicId, DebugLevel Level, const char *Message);
		//! Assert message.
		JA2_CORE_API void assert_message(const char *Condition, const char *Message, long LineNum, const char *FunctionName, const char *SourceFileName);
		//! Register topic.
		JA2_CORE_API void register_debug_topic(RegisterCommand Command, Topic TopicId, const char *Message);
		//! Clear all topics.
		JA2_CORE_API void clear_all_topics();
	private:
		//! Topic exists.
		bool topic_exists(Topic TopicId) const;

		// Construction/Destruction
	public:
		JA2_CORE_API DebugManager(boost::filesystem::path const &WorkingPath);
	};
} /*ja2*/
